package com.zhenyi.jiahua.task;

import java.util.List;

import com.cjw.model.DBMap;
import com.jfinal.kit.JsonKit;
import com.jfinal.kit.LogKit;
import com.jiahua.common.model.JhMessage;
import com.jiahua.common.model.JhStaff;
import com.zhenyi.websocket.core.ws.WSServer;

public class JHTask implements Runnable {

	@Override
	public void run() {
		LogKit.info("send task");
		List<JhStaff> staffs = JhStaff.dao.findAll();
		for (JhStaff jhStaff : staffs) {
			Long staffId = jhStaff.getId();
			JhMessage message = new JhMessage();
			message.setStaffId(staffId);
			message.setTitle("标题");
			message.setContent("content");
			message.save();
			DBMap map = new DBMap();
			map.put("code", 102);
			map.put("title", "标题");
			map.put("content", "content");
			WSServer.instance().sendByToken(jhStaff.getToken(), JsonKit.toJson(map));
		}
	}

}
